package message;

import java.io.File;
import java.net.Socket;

import common.CommonFile;
import common.SendFile;

import serveur.AnnonceurServerDelegate;

public class MessageGetFile extends Message {

	protected String m_sNomFicher;
	private AnnonceurServerDelegate m_AnnonceurServerDelegate;
	private Socket mControlSocket;
	
	public String getM_sNomFicher() {
		return m_sNomFicher;
	}

	public void setM_sNomFicher(String mSNomFicher) {
		m_sNomFicher = mSNomFicher;
	}
	
	public void setM_AnnonceurServerDelegate(AnnonceurServerDelegate m_AnnonceurServerDelegate) {
		this.m_AnnonceurServerDelegate = m_AnnonceurServerDelegate;
	}

	public AnnonceurServerDelegate getM_AnnonceurServerDelegate() {
		return m_AnnonceurServerDelegate;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public MessageGetFile()
	{
		m_iMessageId = Message.GetFileId;
		m_sMessageName = Message.sGetFileName;
		m_sNomFicher = "";
	}
	
	@Override
	public	boolean execute() {
		// TODO Auto-generated method stub
		File FiletoSend = new File( this.m_sCurrentFolder + File.separator + m_sNomFicher );
		System.out.println(FiletoSend.toString());
		SendFile sendFile = new SendFile(FiletoSend, m_AnnonceurServerDelegate.getM_dataSocket(), getmControlSocket());
		sendFile.setM_sFileToSend(m_sNomFicher);
		m_AnnonceurServerDelegate.setM_sendFile( sendFile );
		m_AnnonceurServerDelegate.setM_TransfertMode(CommonFile.SendTranfertMode);
		System.out.println("execute::run");
		m_AnnonceurServerDelegate.run();
		return false;
	}

	public void setmControlSocket(Socket mControlSocket) {
		this.mControlSocket = mControlSocket;
	}

	public Socket getmControlSocket() {
		return mControlSocket;
	}



}
